Vue.component('upload-images', {
    template: `<el-upload class="upload-demo" :show-file-list="false" accept="image/*" drag :on-change="upload" :auto-upload="false" action="" multiple>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">
            只能上传jpg/png文件，且不超过500kb
            <el-slider style="width:350px" :min="1" v-model="quality" :format-tooltip="formatTooltip"></el-slider>
            <div v-show="quality < 100">当前图片压缩至{{quality}}%</div>
        </div>
    </el-upload>
    `,
    props: ['data'],
    data() {
        return {
            quality: 100,
        }
    },
    methods: {
        formatTooltip(val) {
            return '图片压缩比例：' + val + '%';
        },
        upload({ raw }) {
            const that = this;
            new Compressor(raw, {
                quality: that.quality / 100,
                success(file) {
                    const isJPGorPNG = file.type === 'image/jpeg' || file.type === 'image/png';
                    const isLt500K = file.size / 1024 / 1024 < 0.5; // 500KB  
                    if (!isJPGorPNG) {
                        that.$message({
                            message: '上传头像图片只能是 JPG/PNG 格式!',
                            type: 'warning'
                        })
                        return false;
                    }
                    // if (!isLt500K) {
                    //     that.$message({
                    //         message: '上传图片大小不能超过 500KB! 可压缩后上传',
                    //         type: 'warning'
                    //     })
                    //     return false;
                    // }
                    const formData = new FormData();
                    formData.append('file', file, file.name);
                    let oFileReader = new FileReader();
                    oFileReader.readAsDataURL(file);
                    oFileReader.onload = function (e) {
                        that.data.push({
                            Base64: e.target.result,
                            DataLength: file.size,
                            FileName: file.name
                        })
                    }
                },
            });
        }
    }
})
new Vue({
    el: '#app',
    data() {
        return {
            tableData: [],
            headeData: [],
            imageDate: [],
            imageHeader: [],
            image: [],
            isTable: true,
            form: {
                page: 1,
                limit: 15,
            },
            form1: {
                page: 1,
                limit: 15,
            },
            loading: false,
            isBatch: false,
            success: 0,
            warning: 0,
            error: 0,
            multipleSelection: [],
            chack: {},//存放校验信息
            Purchase_Unit_Price_SerialNumber: '',//采购价格单主键
        }
    },
    mixins: [importMixin],
    watch: {
        headeData() {
            const timer = setTimeout(() => {
                this.isTable = true;
                clearTimeout(timer)
            })
        }
    },
    computed: {
        value() {
            return function (str) {
                switch (str) {
                    case "brand":
                        return "品牌";
                    case "category":
                        return "类别";
                    case "classfiy":
                        return "分类";
                    case "item":
                        return "款型";
                    case "series":
                        return "系列";
                }
            }
        },
    },
    methods: {
        submitImage() {
            const that = this;
            if (this.image.length > 0) {
                this.loading = true;
                $.ajax({
                    headers: requestHeaders('JSON'),
                    url: `${BASE_URL2}/article/articlePictureUpLoad`,
                    type: 'POST',
                    data: JSON.stringify(this.image),
                    complete: function (XMLHttpRequest) {
                        that.loading = false;
                        requestPretreatment(XMLHttpRequest);
                    },
                    success: function (Result) {
                        if (Result.Status = "success") {
                            that.$message({
                                message: '上传成功！',
                                type: 'success'
                            })
                            that.update = false;
                            that.update = true;
                        } else {
                            that.$message({
                                message: '图片上传失败，尝试分批上传！',
                                type: 'success'
                            })
                        }
                    },
                    dataType: "json"
                });
            } else {
                this.$message({
                    message: '请先导入图片后再上传',
                    type: 'warning'
                })
            }
        },
        handleImgClick(formName) {//点击查看图片
            this.$refs[formName][0].showViewer = true;
        },
        RemoveImage(index) {//删除图片
            this.image.splice(index, 1);
        },
        is(callback){
            if (!this.headeData.some(i=>i=='销售单价')) {
                this.$confirm('本次导入没有传销售单价字段, 是否继续?(本次导入将不会生成销售价格单)', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    callback();
                }).catch(() => {this.loading = false;});
            }else{
                callback();
            }
        },
        chackUpload() {
            const that = this;
            if (this.tableData.length > 0) {
                this.loading = true;
                this.is(()=>{
                    $.ajax({
                        headers: requestHeaders(),
                        url: `${BASE_URL2}/article/verificationArticleFiles`,
                        type: 'POST',
                        data: {
                            Data: JSON.stringify(this.tableData)
                        },
                        success: function (chack) {
                            if (JSON.stringify(chack) == JSON.stringify({})) {
                                that.submitUpload(0)
                            } else {//校验未通过
                                let obj = {}, html = "<p>部分商品主数据不存在，是否确认生成？</p>"
                                for (let key in chack) {
                                    let value = that.value(key), main = "";
                                    let arr = [];
                                    chack[key].forEach(item => {
                                        if (!arr.some(i => i == item)) {
                                            main += `<span style="margin-right: 10px;color:red;">${item}</span>`;
                                            arr.push(item);
                                        }
                                    })
                                    obj[key] = arr;
                                    html += `<div style="display: flex;">
                                    <span style="font-weight: 700; flex-shrink: 0;">${value}：</span>
                                    <div style="display: flex; flex-wrap: wrap;">${main}</div>
                                </div>`;
                                }
                                that.chack = obj;
                                that.$confirm(html, '提示', {
                                    confirmButtonText: '确定',
                                    cancelButtonText: '取消',
                                    dangerouslyUseHTMLString: true,
                                }).then(() => {
                                    $.ajax({
                                        headers: requestHeaders(),
                                        url: `${BASE_URL2}/article/batchAddArticleBaseInfo`,
                                        type: 'POST',
                                        data: {
                                            Data: JSON.stringify(obj),
                                        },
                                        success: function (res) {
                                            if (res.Status == 'success') {
                                                that.submitUpload(0);
                                            } else {
                                                that.loading = false;
                                                that.$message({
                                                    message: "主数据更新失败",
                                                    duration: 1000,
                                                    type: 'error'
                                                });
                                            }
                                        },
                                        complete: function (XMLHttpRequest) {
                                            requestPretreatment(XMLHttpRequest, false, (res) => {
                                                if (res == 'error') {
                                                    that.loading = false;
                                                    that.$message({
                                                        message: "系统繁忙",
                                                        duration: 1000,
                                                        type: 'error'
                                                    });
                                                    return;
                                                }
                                            });
                                        },
                                        dataType: "json"
                                    })
                                }).catch(() => { that.loading = false; });
                            }
                        },
                        complete: function (XMLHttpRequest) {
                            requestPretreatment(XMLHttpRequest, false, (res) => {
                                if (res == 'error') {
                                    that.loading = false;
                                    that.$message({
                                        message: "系统繁忙",
                                        duration: 1000,
                                        type: 'error'
                                    });
                                    return;
                                }
                            });
                        },
                        dataType: "json"
                    })
                })
                // if (that.tableData[0]['销售单价'] == undefined) {
                //     this.$confirm('本次导入没有传销售单价字段, 是否继续?', '提示', {
                //         confirmButtonText: '确定',
                //         cancelButtonText: '取消',
                //         type: 'warning'
                //     }).then(() => {
                        
                //     }).catch(() => {this.loading = false;});
                // } else {
                    
                // }
            } else {
                this.$message({
                    message: '请先导入模板后再上传',
                    duration: 1000,
                    type: 'warning'
                })
            }
        },
        submitUpload(i = 0) {
            const that = this;
            if (i < this.tableData.length) {
                this.loading = true;
                if (i == 0) {
                    this.success = 0;
                    this.error = 0;
                    this.warning = 0;
                }
                if (this.tableData[i].isStatus == '3') {
                    that.warning++;
                    that.submitUpload(i + 1);
                } else if(isNaN(this.tableData[i]['日库存数量'])) {
                    that.error++;
                    that.tableData[i].Cause = '日库存数量异常'
                    that.tableData[i].isStatus = '2'
                    that.submitUpload(i + 1);
                } else if(!this.tableData[i]['供应商']) {
                    that.error++;
                    that.tableData[i].Cause = '供应商字段异常'
                    that.tableData[i].isStatus = '2'
                    that.submitUpload(i + 1);
                } else {
                    if (that.tableData[i]['封面图片'] == undefined) {
                        that.tableData[i]['封面图片'] = '';
                    }
                    if (that.tableData[i]['销售单价'] == undefined) {
                        that.tableData[i]['销售单价'] == '';
                    }
                    $.ajax({//检查该商品是否存在
                        headers: requestHeaders(),
                        type: 'POST',
                        url: `${BASE_URL2}/generalBusiness/generalQueryBySQLSerialNumber`,
                        data: {
                            SQLSerialNumber: 'A_business_article_specifications1',
                            Condition: window.btoa(unescape(encodeURIComponent(that.tableData[i]['商品名称'] + ',' + that.tableData[i]['品牌'] + ',' + that.tableData[i]['规格']))),
                            ExtensionCondition: '',
                        },
                        success: function (res) {
                            if (res.length == 0) {
                                that.submitForm({ Data: JSON.stringify([that.tableData[i]]) }, (res) => {
                                    if (res.Status == 'success') {
                                        that.tableData[i].isStatus = '1';
                                        that.tableData[i].Cause = '导入成功！';
                                        that.success++;
                                    } else {
                                        that.tableData[i].isStatus = '2';
                                        that.tableData[i].Cause = res.Specifics ? res.Specifics : '未知错误！';
                                        that.error++;
                                    }
                                    that.submitUpload(i + 1);
                                })
                            } else {
                                that.tableData[i].isStatus = '1';
                                that.tableData[i].Cause = '商品存在！';
                                that.success++;
                                that.submitUpload(i + 1);
                            }
                        },
                        complete: function (XMLHttpRequest) {
                            requestPretreatment(XMLHttpRequest);
                        },
                        dataType: "json"
                    })
                }
            } else if (i != 0) {
                if (that.tableData.filter(i => i.isStatus == '1').length > 0) {
                    $.ajax({
                        headers: requestHeaders(),
                        url: `${BASE_URL2}/article/importArticleFiles`,
                        type: 'POST',
                        data: {
                            Data: JSON.stringify(that.tableData.filter(i => i.isStatus == '1'))
                        },
                        success: function (res) {
                            if (res.Status == 'success') {
                                $.ajax({
                                    headers: requestHeaders(),
                                    url: `${BASE_URL2}/article/batchImportArticlePicture`,
                                    type: 'POST',
                                    data: {
                                        Data: JSON.stringify(that.imageDate)
                                    },
                                    success: function (res) {
                                        if (res.Status == 'success') {
                                            //导入条形码
                                            that.submitBarCode(0)
                                        } else {
                                            that.loading = false;
                                            that.$message({
                                                message: res.Specifies ? res.Specifies : "批量导入失败，请联系管理员！",
                                                duration: 1000,
                                                type: 'error'
                                            })
                                            that.imageDate.forEach(item => {
                                                item.isStatus = '2';
                                                item.Cause = res.Specifics ? res.Specifics : '未知错误！';
                                            })
                                        }
                                    },
                                    error: function () {
                                        that.loading = false;
                                        that.$message({
                                            message: "系统繁忙",
                                            duration: 1000,
                                            type: 'error'
                                        })
                                    },
                                    complete: function (XMLHttpRequest) {
                                        requestPretreatment(XMLHttpRequest);
                                    },
                                    dataType: "json"
                                })
                            } else {
                                that.loading = false;
                                that.$message({
                                    message: res.Specifies ? res.Specifies : "批量导入失败，请联系管理员！",
                                    duration: 1000,
                                    type: 'error'
                                })
                            }
                        },
                        error: function () {
                            that.loading = false;
                            that.$message({
                                message: "系统繁忙",
                                duration: 1000,
                                type: 'error'
                            })
                        },
                        complete: function (XMLHttpRequest) {
                            requestPretreatment(XMLHttpRequest);
                        },
                        dataType: "json"
                    })
                } else {
                    //上传条码
                    that.submitBarCode(0)
                }
            } else {
                this.$message({
                    message: '请先导入模板后再上传',
                    duration: 1000,
                    type: 'warning'
                })
            }
        },
        submitBarCode(i = 0) {//导入条形码
            const that = this;
            let tableData = this.tableData.filter(i => i.isStatus == '1' && i['条形码']);
            if (i < tableData.length) {
                //查询规格编号
                $.ajax({
                    headers: requestHeaders(),
                    type: 'POST',
                    url: `${BASE_URL2}/generalBusiness/generalQueryBySQLSerialNumber`,
                    data: {
                        SQLSerialNumber: 'A_business_article_specifications1',
                        Condition: window.btoa(unescape(encodeURIComponent(tableData[i]['商品名称'] + ',' + tableData[i]['品牌'] + ',' + tableData[i]['规格']))),
                        ExtensionCondition: '',
                    },
                    success: function (Result) {
                        if (Result.length == 1) {
                            let Article_Specifications_SerialNumber = Result[0].Article_Specifications_SerialNumber;
                            let business_article_barcode = [{
                                Article_Specifications_SerialNumber,
                                BarCode: tableData[i]['条形码']
                            }]
                            //判读该条码是否添加过
                            $.ajax({
                                headers: requestHeaders(),
                                url: `${BASE_URL2}/generalBusiness/generalQueryByTableName`,
                                type: 'POST',
                                data: {
                                    Data: 'business_article_barcode',
                                    Condition: "BarCode='" + tableData[i]['条形码'] + "' AND Article_Specifications_SerialNumber='" + Article_Specifications_SerialNumber + "'",
                                },
                                success: function (data) {
                                    if (data.length == 0) {//判读该条码是否存在
                                        that.submitForm1({ Data: JSON.stringify({ Add: { business_article_barcode } }) }, (res) => {
                                            if (res.Status == 'success') {
                                                $.ajax({
                                                    headers: requestHeaders(),
                                                    url: `${BASE_URL2}/generalBusiness/generalQueryByTableName`,
                                                    type: 'POST',
                                                    data: {
                                                        Data: 'business_article_barcode',
                                                        Condition: "BarCode='" + tableData[i]['条形码'] + "'",
                                                    },
                                                    success: function (data) {
                                                        if (data.length != 0) {
                                                            that.tableData[i].Cause += '（提示：该条码已存在）';
                                                        }
                                                        that.submitBarCode(i + 1);
                                                    },
                                                    complete: function (XMLHttpRequest) {
                                                        requestPretreatment(XMLHttpRequest);
                                                    },
                                                    dataType: "json"
                                                });
                                            } else {
                                                tableData[i].Cause += '条形码添加失败！';
                                                that.submitBarCode(i + 1);
                                            }
                                        })
                                    } else {
                                        that.submitBarCode(i + 1);
                                    }
                                },
                                complete: function (XMLHttpRequest) {
                                    requestPretreatment(XMLHttpRequest);
                                },
                                dataType: "json"
                            });
                        }
                    },
                    error: function () {
                        tableData[i].Cause += '条形码添加失败！';
                        that.submitBarCode(i + 1);
                    },
                    complete: function (XMLHttpRequest) {
                        requestPretreatment(XMLHttpRequest);
                    },
                    dataType: "json"
                })
            } else {//条形码导入结束
                //导入积分配置
                this.submitPointsConfig(0);
            }
        },
        submitPointsConfig(i = 0) {//导入积分配置
            const that = this;
            let tableData = this.tableData.filter(i => i.isStatus == '1' && i['可适用积分'] && (i['抵扣类型'] == 0 || i['抵扣类型'] == 1) && !isNaN(i['抵扣比例']) && i['抵扣比例'] > 0);
            if (i < tableData.length) {
                //查询规格编号
                $.ajax({
                    headers: requestHeaders(),
                    type: 'POST',
                    url: `${BASE_URL2}/generalBusiness/generalQueryBySQLSerialNumber`,
                    data: {
                        SQLSerialNumber: 'A_business_supplier_article4',
                        Condition: window.btoa(unescape(encodeURIComponent(tableData[i]['商品名称'] + ',' + tableData[i]['品牌'] + ',' + tableData[i]['规格'] + ',' + tableData[i]['供应商']))),
                        ExtensionCondition: '',
                    },
                    success: function (Result) {
                        if (Result.length == 1) {
                            let Supplier_Article_SerialNumber = Result[0].Supplier_Article_SerialNumber;
                            let Pionts = tableData[i]['可适用积分'].split(';');
                            let business_points_detail_config = [{
                                Points_Detail_Config_SerialNumber: '',
                                Supplier_Article_SerialNumber,
                                Gift_Point: Pionts.some(i => i == '赠送积分') ? '0' : '1',
                                Sales_Point: Pionts.some(i => i == '消费积分') ? '0' : '1',
                                Cash_Point: Pionts.some(i => i == '现金积分') ? '0' : '1',
                                Activit_Point: Pionts.some(i => i == '活动积分') ? '0' : '1',
                                Deduction_Type: tableData[i]['抵扣类型'],
                                Deduction_Limit: tableData[i]['抵扣比例'],
                                Combination: '1',
                            }]
                            that.submitForm1({ Data: JSON.stringify({ Add: { business_points_detail_config } }) }, (res) => {
                                if (res.Status == 'success') {
                                    that.submitPointsConfig(i + 1);
                                } else {
                                    tableData[i].Cause += '积分适用方案配置失败！';
                                    that.submitPointsConfig(i + 1);
                                }
                            })
                        } else {
                            tableData[i].Cause += '积分适用方案配置失败！';
                            that.submitPurchaseUnitprice(i + 1);
                        }
                    },
                    error: function () {
                        tableData[i].Cause += '积分适用方案配置失败！';
                        that.submitPointsConfig(i + 1);
                    },
                    complete: function (XMLHttpRequest) {
                        requestPretreatment(XMLHttpRequest);
                    },
                    dataType: "json"
                })
            } else {//条形码导入结束
                //导入采购价格单
                this.submitPurchaseUnitprice(0)
            }
        },
        submitPurchaseUnitprice(i = 0) {//导入采购价格单
            const that = this;
            let tableData = this.tableData.filter(i => i.isStatus == '1' && !isNaN(i['采购单价']) && i['采购单价'] > 0);
            if (i < tableData.length) {
                //查询规格编号
                $.ajax({
                    headers: requestHeaders(),
                    type: 'POST',
                    url: `${BASE_URL2}/generalBusiness/generalQueryBySQLSerialNumber`,
                    data: {
                        SQLSerialNumber: 'A_business_supplier_article4',
                        Condition: window.btoa(unescape(encodeURIComponent(tableData[i]['商品名称'] + ',' + tableData[i]['品牌'] + ',' + tableData[i]['规格'] + ',' + tableData[i]['供应商']))),
                        ExtensionCondition: '',
                    },
                    success: function (Result) {
                        if (Result.length == 1) {
                            let Supplier_Article_SerialNumber = Result[0].Supplier_Article_SerialNumber;
                            let data = {};
                            if (i == 0) { //首次添加
                                let obj = {
                                    Purchase_Unit_Price_SerialNumber: '',
                                    Start_Date: getYMDDate(),//开始时间
                                    End_Date: '',//结束时间
                                    Enterprise_Info_SerialNumber: '',
                                    Children: {
                                        business_purchase_unitprice_detail: [{
                                            Purchase_Unit_Price_Detail_SerialNumber: '',
                                            Purchase_Unit_Price_SerialNumber: '',
                                            Supplier_Article_SerialNumber,
                                            Purchase_Unit_Price: tableData[i]['采购单价'],
                                            Brand_SerialNumber: tableData[i]['品牌']
                                        }],
                                    }
                                }
                                data = { Add: { business_purchase_unitprice: [obj] } };
                            } else {//后续添加只添加到子表
                                let obj = {
                                    Purchase_Unit_Price_Detail_SerialNumber: '',
                                    Purchase_Unit_Price_SerialNumber: that.Purchase_Unit_Price_SerialNumber,
                                    Supplier_Article_SerialNumber,
                                    Purchase_Unit_Price: tableData[i]['采购单价'],
                                    Brand_SerialNumber: tableData[i]['品牌']
                                }
                                data = { Add: { business_purchase_unitprice_detail: [obj] } };
                            }
                            that.submitForm1({ Data: JSON.stringify(data) }, (res) => {
                                if (res.Status == 'success') {
                                    if (i == 0) {
                                        that.Purchase_Unit_Price_SerialNumber = res.Data;
                                    }
                                    that.submitPurchaseUnitprice(i + 1);
                                } else {
                                    tableData[i].Cause += '采购价格单添加失败！';
                                    that.submitPurchaseUnitprice(i + 1);
                                }
                            })
                        } else {
                            tableData[i].Cause += '采购价格单添加失败！';
                            that.submitPurchaseUnitprice(i + 1);
                        }
                    },
                    error: function () {
                        tableData[i].Cause += '采购价格单添加失败！';
                        that.submitPurchaseUnitprice(i + 1);
                    },
                    complete: function (XMLHttpRequest) {
                        requestPretreatment(XMLHttpRequest);
                    },
                    dataType: "json"
                })
            } else {
                $.ajax({
                    headers: requestHeaders(),
                    url: `${BASE_URL2}/article/generateDailyArticlePurchasePrice`,
                    type: 'GET',
                    complete: function (XMLHttpRequest) {
                        if (XMLHttpRequest.status == 200) {
                            that.loading = false;
                            that.$message({
                                message: "批量导入结束",
                                duration: 1000,
                                type: 'success'
                            })
                        }
                    },
                })
            }
        },
        submitForm(data, callback) {
            $.ajax({
                headers: requestHeaders(),
                url: `${BASE_URL2}/article/importArticleInfo`,
                type: 'POST',
                data,
                success: function (res) {
                    callback(res)
                },
                error: function () {
                    callback({ Result: '失败', Status: 'fail' })
                },
                complete: function (XMLHttpRequest) {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json"
            })
        },
        submitForm1(data, callback) {
            $.ajax({
                headers: requestHeaders(),
                url: `${BASE_URL2}/generalBusiness/generalSave`,
                type: 'POST',
                data,
                success: function (res) {
                    callback(res)
                },
                complete: function (XMLHttpRequest) {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json"
            })
        },
        handleChange({ raw }) {//导入监听文件
            const that = this;
            var reader = new FileReader();
            reader.readAsBinaryString(raw);
            reader.onload = function (e) {
                var data = e.target.result;
                var wb = XLSX.read(data, {
                    type: 'binary' //以二进制的方式读取
                });
                var sheet = wb.Sheets[wb.SheetNames[0]];//sheet0代表excel表格中的第一页
                var sheet1 = wb.Sheets[wb.SheetNames[1]];//sheet1代表excel表格中的第一页
                var header = XLSX.utils.sheet_to_json(sheet, { header: 1 })[0];//获取
                that.imageHeader = XLSX.utils.sheet_to_json(sheet1, { header: 1 })[0];//获取
                var json = XLSX.utils.sheet_to_json(sheet);//利用接口实现转换。
                that.imageDate = image = XLSX.utils.sheet_to_json(sheet1);//利用接口实现转换。
                json.forEach(item => {
                    item.isEdit = false;
                    item.isStatus = '';
                    item.Cause = '';
                })
                that.isTable = false;
                that.headeData = header;
                that.tableData = json;
            }
        },
        // selectable(row) {
        //     return row.isStatus == '3';
        // },
        // tableCellStyle({ row }) {
        //     if (row.isStatus == '3') return { background: '#E6A23C', color: '#fff' }
        // },
        handleSizeChange(val, id) {
            this[id].page = 1;
            this[id].limit = val;
        },
        handleCurrentChange(val, id) {
            this[id].page = val;
        },
        // handleSelectionChange(val) {//批量选择
        //     this.multipleSelection = val;
        // },
        // handleBatch() {
        //     const that = this;
        //     if (this.multipleSelection.length > 0) {
        //         this.$confirm('是否对已选中的数据添加该部门并完成导入?', '提示', {
        //             confirmButtonText: '确定',
        //             cancelButtonText: '取消',
        //             type: 'warning',
        //         }).then(() => {
        //             // this.loading = true;
        //             this.isBatch = true;
        //             $.ajax({
        //                 headers: requestHeaders(),
        //                 url: `${BASE_URL2}/article/verificationArticleFiles`,
        //                 type: 'POST',
        //                 data: {
        //                     Data: JSON.stringify(this.multipleSelection)
        //                 },
        //                 success: function (chack) {
        //                     if (JSON.stringify(chack) != JSON.stringify({})) {
        //                         //去重
        //                         let obj = {};
        //                         for (let key in chack) {
        //                             let arr = [];
        //                             chack[key].forEach(item => {
        //                                 if (!arr.some(i => i == item)) {
        //                                     arr.push(item);
        //                                 }
        //                             })
        //                             obj[key] = arr;
        //                         }
        //                         $.ajax({
        //                             headers: requestHeaders(),
        //                             url: `${BASE_URL2}/article/batchAddArticleBaseInfo`,
        //                             type: 'POST',
        //                             data: {
        //                                 Data: JSON.stringify(obj),
        //                             },
        //                             success: function (res) {
        //                                 if (JSON.parse(res).Status == 'success') {
        //                                     that.submitForm({ Data: JSON.stringify(that.multipleSelection) }, (res) => {
        //                                         if (res.Status == 'success') {
        //                                             that.multipleSelection.forEach(row => {
        //                                                 row.isStatus = '1';
        //                                                 row.Cause = '导入成功！';
        //                                             })
        //                                             that.warning = that.warning - that.multipleSelection.length;
        //                                             that.success = that.success + that.multipleSelection.length;
        //                                         } else {
        //                                             that.multipleSelection.forEach(row => {
        //                                                 row.isStatus = '2';
        //                                                 row.Cause = res.Specifics ? res.Specifics : '未知错误！'
        //                                             })
        //                                             that.warning = that.warning - that.multipleSelection.length;
        //                                             that.error = that.error + that.multipleSelection.length;
        //                                         }
        //                                         that.$refs.multipleTable.clearSelection();
        //                                         that.loading = false;
        //                                         that.isBatch = false;
        //                                     })
        //                                 } else {
        //                                     that.multipleSelection.forEach(row => {
        //                                         row.isStatus = '2';
        //                                         row.Cause = '商品主数据添加失败';
        //                                     })
        //                                     that.warning = that.warning - that.multipleSelection.length;
        //                                     that.error = that.error + that.multipleSelection.length;
        //                                     that.$refs.multipleTable.clearSelection();
        //                                     that.loading = false;
        //                                     that.isBatch = false;
        //                                 }
        //                             },
        //                             complete: function (XMLHttpRequest) {
        //                                 requestPretreatment(XMLHttpRequest);
        //                             },
        //                             dataType: "text"
        //                         })
        //                     } else {
        //                         that.submitForm({ Data: JSON.stringify(that.multipleSelection) }, (res) => {
        //                             if (res.Status == 'success') {
        //                                 that.multipleSelection.forEach(row => {
        //                                     row.isStatus = '1';
        //                                     row.Cause = '导入成功！';
        //                                 })
        //                                 that.warning = that.warning - that.multipleSelection.length;
        //                                 that.success = that.success + that.multipleSelection.length;
        //                             } else {
        //                                 that.multipleSelection.forEach(row => {
        //                                     row.isStatus = '2';
        //                                     row.Cause = res.Specifics ? res.Specifics : '未知错误！'
        //                                 })
        //                                 that.warning = that.warning - that.multipleSelection.length;
        //                                 that.error = that.error + that.multipleSelection.length;
        //                             }
        //                             that.$refs.multipleTable.clearSelection();
        //                             that.loading = false;
        //                             that.isBatch = false;
        //                         })
        //                     }
        //                 },
        //                 complete: function (XMLHttpRequest) {
        //                     requestPretreatment(XMLHttpRequest, false, (res) => {
        //                         that.loading = false;
        //                         that.isBatch = false;
        //                         that.$message({
        //                             message: '系统繁忙!',
        //                             duration: 1000,
        //                             type: 'error'
        //                         });
        //                         if (res == 'error') {
        //                             return;
        //                         }
        //                     });
        //                 },
        //             })
        //         }).catch(() => { });
        //     } else {
        //         this.$message({
        //             message: '当前没有选择待确认数据!',
        //             duration: 1000,
        //             type: 'warning'
        //         })
        //     }
        // },
        handleEdit(row) {//修改当前行
            row.isEdit = !row.isEdit
        },
        // handleSubmit(row) {//确认
        //     const that = this;
        //     if (row.isStatus == '3') {
        //         if (this.multipleSelection.some(item => item['商品编号'] == row['商品编号']) && this.isBatch) {
        //             this.$message({
        //                 message: '当前数据正在批量导入!',
        //                 duration: 1000,
        //                 type: 'warning'
        //             })
        //         } else {
        //             this.$confirm('是否要添加该部门并完成导入?', '提示', {
        //                 confirmButtonText: '确定',
        //                 cancelButtonText: '取消',
        //                 type: 'warning',
        //             }).then(() => {
        //                 $.ajax({
        //                     headers: requestHeaders(),
        //                     url: `${BASE_URL2}/article/verificationArticleFiles`,
        //                     type: 'POST',
        //                     data: {
        //                         Data: JSON.stringify([row])
        //                     },
        //                     success: function (chack) {
        //                         if (JSON.stringify(chack) != JSON.stringify({})) {
        //                             $.ajax({
        //                                 headers: requestHeaders(),
        //                                 url: `${BASE_URL2}/article/batchAddArticleBaseInfo`,
        //                                 type: 'POST',
        //                                 data: {
        //                                     Data: JSON.stringify(chack),
        //                                 },
        //                                 success: function (res) {
        //                                     if (JSON.parse(res).Status == 'success') {
        //                                         that.submitForm({ Data: JSON.stringify([row]) }, (res) => {
        //                                             if (res.Status == 'success') {
        //                                                 row.isStatus = '1';
        //                                                 row.Cause = '导入成功！';
        //                                                 that.warning--;
        //                                                 that.success++;
        //                                             } else {
        //                                                 row.isStatus = '2';
        //                                                 row.Cause = res.Specifics ? res.Specifics : '未知错误！'
        //                                                 that.warning--;
        //                                                 that.error++;
        //                                             }
        //                                         })
        //                                     } else {
        //                                         row.isStatus = '2';
        //                                         row.Cause = '商品主数据添加失败';
        //                                         that.warning--;
        //                                         that.error++;
        //                                     }
        //                                 },
        //                                 complete: function (XMLHttpRequest) {
        //                                     requestPretreatment(XMLHttpRequest);
        //                                 },
        //                                 dataType: "text"
        //                             })
        //                         } else {
        //                             that.submitForm({ Data: JSON.stringify([row]) }, (res) => {
        //                                 if (res.Status == 'success') {
        //                                     row.isStatus = '1';
        //                                     row.Cause = '导入成功！';
        //                                     that.warning--;
        //                                     that.success++;
        //                                 } else {
        //                                     row.isStatus = '2';
        //                                     row.Cause = '未知错误！';
        //                                     that.warning--;
        //                                     that.error++;
        //                                 }
        //                             })
        //                         }
        //                     },
        //                     complete: function (XMLHttpRequest) {
        //                         requestPretreatment(XMLHttpRequest, false, (res) => {
        //                             that.loading = false;
        //                             that.$message({
        //                                 message: '系统繁忙!',
        //                                 duration: 1000,
        //                                 type: 'error'
        //                             });
        //                             if (res == 'error') {
        //                                 return;
        //                             }
        //                         });
        //                     },
        //                 })
        //             }).catch(() => { });
        //         }
        //     }
        // },
        handleRemove(index, id) {//移除当前行
            this.$confirm('是否要删除此行?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                if (id == "form") {
                    this.tableData = this.tableData.filter((i, id) => id != (this.form.page - 1) * this.form.limit + index)
                } else if (id == 'form1') {
                    this.imageDate = this.imageDate.filter((i, id) => id != (this.form1.page - 1) * this.form1.limit + index)
                }

            }).catch(() => { });
        },
        handleClean() {//清空
            this.$confirm('是否要清空导入数据?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                this.tableData = [];
                this.imageDate = [];
            }).catch(() => { });
        },
    },
})